package com.util.excel;

import java.math.BigDecimal;
import java.util.*;

/**
 * Created by lvjianqing on 2017/9/12.
 */
public class Test {
    public static void main(String[] args) throws Exception {
        System.out.println("写Excel");

        List<User> list = new ArrayList<User>();
        User u = new User();
        u.setAge("3");
        u.setName("fdsafdsa");
        u.setXx(123.23D);
        u.setYy(new Date());
        u.setLocked(false);
        u.setDb(new BigDecimal(123));
        list.add(u);

        u = new User();
        u.setAge("23");
        u.setName("fdsafdsa");
        u.setXx(123.23D);
        u.setYy(new Date());
        u.setLocked(true);
        u.setDb(new BigDecimal(234));
        list.add(u);

        u = new User();
        u.setAge("123");
        u.setName("fdsafdsa");
        u.setXx(123.23D);
        u.setYy(new Date());
        u.setLocked(false);
        u.setDb(new BigDecimal(2344));
        list.add(u);

        u = new User();
        u.setAge("22");
        u.setName("fdsafdsa");
        u.setXx(123.23D);
        u.setYy(new Date());
        u.setLocked(true);
        u.setDb(new BigDecimal(908));
        list.add(u);

        ExcelDataFormatter edf = new ExcelDataFormatter();
        Map<String, String> map = new HashMap<String, String>();
        map.put("true", "真");
        map.put("false", "假");
        edf.set("locked", map);

        ExcelUtils<User> excelUtil = new ExcelUtils<User>(new User());

        excelUtil.writeToFile(list,edf, "/Users/lvjianqing/IdeaProjects/temp/x.xlsx");

//        List<User> xx = new ExcelUtils<User>(new User()).readFromFile(edf, new File("/Users/lvjianqing/IdeaProjects/temp/x.xlsx"));
//        System.out.println(JSON.toJSONString(xx));



    }
}
